﻿
Partial Class WebForm_ManageWorkRecord
    Inherits My.MyPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            '      Me.InitData()

            '只有管理權限才可以匯入年度時數 Mod by Shihyu 2011/08/02
            If Me.CanAdmin = True Then
                Me.ImportHourTabPanel.Visible = True
            End If
            listOrgV2.DataBind()

            listPlanItemTypeV2.DataBind()
            listWorkItemV2.DataBind()
            listRegionV2.DataBind()
        End If

        Me.Form.Enctype = "multipart/form-data"
    End Sub

#Region "CleanPlan"

    Protected Sub lbtnAddPlan_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnAddPlan.Click
        'Me.TabContainer1.ActiveTab = Me.AddCleanPlanTabPanel
        mvClean.SetActiveView(vwAdd)
        '新增模式
        Me.AddCleanPlan1.DataAccessMode = FormViewMode.Insert
        Me.AddCleanPlan1.InitData(0, 0)

    End Sub
    Protected Sub lbtnReturn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnReturn.Click
        mvClean.SetActiveView(vwSearch)

    End Sub
    Protected Sub SearchCleanPlan_Edit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SearchCleanPlan1.Edit_Click
        '單筆檢視模式
        'Me.AddCleanPlanTabPanel.Enabled = True
        ' Me.TabContainer1.ActiveTab = Me.AddCleanPlanTabPanel
        mvClean.SetActiveView(vwAdd)
        Me.AddCleanPlan1.DataAccessMode = FormDataAccessMode.Execute
        Me.AddCleanPlan1.InitData(Me.SearchCleanPlan1.SelectedPlanID, Me.SearchCleanPlan1.SelectedWorkHeaderID)
        '    Me.SearchCleanPlan1.BindGV()
    End Sub

    '在新增編輯頁按下存檔
    Protected Sub AddCleanPlan1_Save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddCleanPlan1.Save_Click
        'If Me.AddCleanPlan1.DataAccessMode <> FormDataAccessMode.Take Then
        '    Me.TabContainer1.ActiveTab = Me.SearchCleanPlanTabPanel
        'End If
        If Me.AddCleanPlan1.DataAccessMode <> FormDataAccessMode.Take Then
            mvClean.SetActiveView(vwSearch)
        End If
        ' Me.SearchCleanPlan1.UOrganizationID = Me.AddCleanPlan1.UOrganizationID
        ' Me.SearchCleanPlan1.VOrganizationID = Me.AddCleanPlan1.VOrganizationID.Split(",")(1).ToString().Trim()
        '   Me.SearchCleanPlan1.InitData()
        '  Me.SearchCleanPlan1.BindGV()

    End Sub

    Protected Sub SearchCleanPlan1_OrgIndexChange(ByVal source As Object, ByVal e As System.EventArgs) Handles SearchCleanPlan1.OrgIndexChange
        UOrganizationID = Me.SearchCleanPlan1.UOrganizationID
        listVOrgV2.DataBind()
        listCleanPlanV2.DataBind()
    End Sub

    Protected Sub SearchCleanPlan1_PlanItemTypeChange(ByVal source As Object, ByVal e As System.EventArgs) Handles SearchCleanPlan1.PlanItemTypeChange
        listCleanPlanV2.DataBind()
    End Sub


    Protected Sub SearchCleanPlan1_Selecting(ByVal source As Object, ByVal e As System.EventArgs) Handles SearchCleanPlan1.Selecting
        'Me.AddCleanPlanTabPanel.Enabled = True
        'Me.TabContainer1.ActiveTab = Me.AddCleanPlanTabPanel
        mvClean.SetActiveView(vwAdd)
        Me.AddCleanPlan1.DataAccessMode = FormDataAccessMode.View
        Me.AddCleanPlan1.InitData(Me.SearchCleanPlan1.SelectedPlanID, Me.SearchCleanPlan1.SelectedWorkHeaderID)
    End Sub
#End Region

#Region "FindDirtyHeader"
    Protected Sub lbtnDyReturn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnDyReturn.Click
        mvDirty.SetActiveView(vwDySearch)

    End Sub
    Protected Sub lbtnAddDirty_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnAddDirty.Click
        'Me.TabContainer1.ActiveTab = Me.AddDirtyHeaderTabPanel
        mvDirty.SetActiveView(vwDyAdd)
        '新增模式
        Me.AddDirtyHeader1.DataAccessMode = FormViewMode.Insert
        Me.AddDirtyHeader1.InitData(0, 0)

    End Sub

    Protected Sub SearchDirtyHeader_Edit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SearchDirtyHeader1.Edit_Click
        '單筆檢視模式
        'Me.AddDirtyHeaderTabPanel.Enabled = True
        'Me.TabContainer1.ActiveTab = Me.AddDirtyHeaderTabPanel
        mvDirty.SetActiveView(vwDyAdd)
        Me.AddDirtyHeader1.DataAccessMode = WebForm_ManageWorkRecord_AddDirtyHeader.FormDataAccessMode.Execute
        Me.AddDirtyHeader1.InitData(Me.SearchDirtyHeader1.SelectedPlanID, Me.SearchDirtyHeader1.SelectedWorkHeaderID)
    End Sub

    '在新增編輯頁按下存檔
    Protected Sub AddDirtyHeader1_Save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddDirtyHeader1.Save_Click
        If Me.AddDirtyHeader1.DataAccessMode <> WebForm_ManageWorkRecord_AddDirtyHeader.FormDataAccessMode.Take Then
            mvDirty.SetActiveView(vwDySearch)
        End If

        Me.SearchDirtyHeader1.InitData()
    End Sub

    Protected Sub SearchDirtyHeader1_RegionChange(ByVal source As Object, ByVal e As System.EventArgs) Handles SearchDirtyHeader1.RegionChange
        listVillageNameV2.DataBind()
    End Sub

    Protected Sub SearchDirtyHeader1_Selecting(ByVal source As Object, ByVal e As System.EventArgs) Handles SearchDirtyHeader1.Selecting
        '單筆檢視模式
        'Me.AddDirtyHeaderTabPanel.Enabled = True
        'Me.TabContainer1.ActiveTab = Me.AddDirtyHeaderTabPanel
        mvDirty.SetActiveView(vwDyAdd)
        Me.AddDirtyHeader1.DataAccessMode = WebForm_ManageWorkRecord_AddDirtyHeader.FormDataAccessMode.View
        Me.AddDirtyHeader1.InitData(Me.SearchDirtyHeader1.SelectedPlanID, Me.SearchDirtyHeader1.SelectedWorkHeaderID)
    End Sub
#End Region




    ''在新增編輯頁按下簽到退
    'Protected Sub AddEnlistment_Check_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddEnlistment1.Check_Click
    '    Me.EnlistmentPersonCheckTabPanel.Visible = True
    '    Me.TabContainer1.ActiveTab = Me.EnlistmentPersonCheckTabPanel
    '    Me.EnlistmentPersonCheck1.InitData(AddEnlistment1.CourseID)
    'End Sub

    Protected Sub SearchCleanPlan1_Taking(ByVal source As Object, ByVal e As System.EventArgs) Handles SearchCleanPlan1.Taking
        'Me.AddCleanPlanTabPanel.Enabled = True
        'Me.TabContainer1.ActiveTab = Me.AddCleanPlanTabPanel
        mvClean.SetActiveView(vwAdd)
        '新增模式
        Me.AddCleanPlan1.DataAccessMode = FormViewMode.Insert
        Me.AddCleanPlan1.InitData(Me.SearchCleanPlan1.SelectedPlanID, 0)
    End Sub


    Protected Sub SearchDirtyHeader1_Taking(ByVal source As Object, ByVal e As System.EventArgs) Handles SearchDirtyHeader1.Taking
        'Me.AddDirtyHeaderTabPanel.Enabled = True
        'Me.TabContainer1.ActiveTab = Me.AddDirtyHeaderTabPanel
        mvDirty.SetActiveView(vwDyAdd)
        Me.AddDirtyHeader1.DataAccessMode = FormViewMode.Insert
        Me.AddDirtyHeader1.InitData(Me.SearchDirtyHeader1.SelectedPlanID, 0)
    End Sub

    Protected Sub SearchWorkRecord1_Active(ByVal source As Object, ByVal e As System.EventArgs) Handles SearchWorkRecord1.Active
        Me.TabContainer1.ActiveTab = Me.SearchWorkRecordTabPanel
    End Sub

    Protected Sub SearchWorkRecord1_OrgIndexChange(ByVal source As Object, ByVal e As System.EventArgs) Handles SearchWorkRecord1.OrgIndexChange
        UOrganizationID = Me.SearchWorkRecord1.OrganizationID
        listVOrgV2.DataBind()
    End Sub

    Protected Sub SearchWorkRecord1_PlanName(ByVal source As Object, ByVal e As System.EventArgs) Handles SearchWorkRecord1.PlanName
        Me.listPleanNameV2.DataBind()
    End Sub

    Protected Sub ImportWorkRecord1_OrgIndexChange(ByVal source As Object, ByVal e As System.EventArgs) Handles ImportWorkRecord1.OrgIndexChange
        UOrganizationID = Me.ImportWorkRecord1.UOrganizationID
        listVOrgV2.DataBind()
    End Sub
End Class

Partial Class WebForm_ManageWorkRecord

    Private Sub InitData()
        'Me.SearchCleanPlan1.InitData()
        ' Me.AddCleanPlan1.InitData(0, 0)
        '    Me.AddCleanPlanTabPanel.Enabled = False

        'Me.SearchDirtyHeader1.InitData()
        ' Me.AddDirtyHeader1.InitData(0, 0)
        '  Me.AddDirtyHeaderTabPanel.Enabled = False
    End Sub

    Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
        '處理'GridView' 的控制項 'GridView' 必須置於有 runat=server 的表單標記之中
    End Sub

    Public Property UOrganizationID() As String
        Get
            Return ViewState("UOrganizationID")
        End Get
        Set(ByVal value As String)
            ViewState("UOrganizationID") = value
        End Set
    End Property

End Class